from tkinter import *
import os
import tkinter.messagebox
from matplotlib import *
import pygame


def exec():
    os.execl("千束射击模拟器.exe", "千束射击模拟器.exe")


def show():
    tkinter.messagebox.showinfo(title='提示', message='游戏按下空格结束')


def end():
    exit()


# command事件处理
def start():
    pygame.mixer.music.stop()  # 暂停音乐播放
    show()
    exec()  # 进程替换，原本存在在本程序加载入内存的全部木大


# 音乐播放
pygame.mixer.init()  # 初始化
pygame.mixer.music.load('res2/反击.mp3')  # 绝对路径  利用pygame加载入MP3文件
pygame.mixer.music.play(-1, 0.3)  # -1循环播放 0.3秒后执行

win = Tk()
# 添加图片
canvas = Canvas(width=1096,height=982,bd=0, highlightthickness=0)
photo = PhotoImage(file='res2/帝皇.png')
canvas.create_image(300, 350, image=photo)
canvas.pack()

label = Label(text='铁驭，选择你的方向！')
label.config(fg='red', font=('宋体', 30))
label.place(x=70, y=100)
# label.pack()

btn1 = Button(text='林肯死大头！', command=start, fg='black', font=('经典雅黑', 18))
btn2 = Button(text='你给路哒哟！', command=end, fg='black', font=('经典雅黑', 18))
btn1.place(x=180, y=180)
btn2.place(x=180, y=230)
# btn1.pack()
# btn2.pack()

win.title("射击模拟器")
win.geometry("500x400")
win.iconphoto(False, PhotoImage(file='res2/窗口.png'))  # 设置窗口小图标
# win.overrideredirect(True)
win.mainloop()
